package br.com.fogas.webservice.repository.soap;

import android.content.Context;
import br.com.fogas.utils.exception.ParseXmlException;
import br.com.fogas.webservice.exception.RespostaWebServiceException;
import br.com.fogas.webservice.exception.SemConexaoInternetException;
import br.com.fogas.webservice.exception.ServidorForaException;
import br.com.fogas.webservice.exception.TempoEsperaRespostaException;
import br.com.fogas.webservice.exception.WebServiceException;
import br.com.fogas.webservice.parser.material.MaterialEnvelope;
import br.com.fogas.webservice.parser.material.MaterialRequest;
import br.com.fogas.webservice.parser.material.MaterialResponse;
import br.com.fogas.webservice.repository.IRepositoryHandler;
import br.com.fogas.webservice.soap.impl.MaterialSOAP;

public class MaterialRepository implements IRepositoryHandler<MaterialResponse> {

	private Context context;
	
	private MaterialRequest request;

	public MaterialRepository(Context context, MaterialRequest request) {
		this.context = context;
		this.request = request;
	}
	
	@Override
	public MaterialResponse getResponse() throws SemConexaoInternetException,
			ParseXmlException, TempoEsperaRespostaException,
			ServidorForaException, RespostaWebServiceException,
			WebServiceException {
		MaterialEnvelope envelope = new MaterialEnvelope();
		envelope.body.request = request;

		MaterialSOAP soap = new MaterialSOAP(context, envelope);
		return soap.getResponse();
	}

}
